<?php
/**************************************************************************************************
|
| AudioShare - Audio Sharing Script
| http://www.audiosharescript.com
| webmaster@audiosharescript.com
|
|**************************************************************************************************
|
| By using this software you agree that you have read and acknowledged our End-User License 
| Agreement available at http://www.audiosharescript.com/eula.html and to be bound by it.
|
| Copyright (c) 2010 AudioShareScript.com. All rights reserved.
|**************************************************************************************************/

include("include/config.php");
include("include/functions/import.php");

//MOST VIDEOS AUDIOS BEGIN
$category = $_POST["categories"];

$home_view_audios = 20;
$queryCategory = "";
if($category > 0) {
	$queryCategory .= " AND categories = '".$category."' ";
	
}
else{
	//$query="SELECT a.AUDIOID,title,ext,count(a.AUDIOID) as viewcount,username FROM audios AS a LEFT JOIN members AS m ON m.USERID = a.USERID left join audios_viewed av on av.AUDIOID=a.AUDIOID WHERE public='1' AND active='1' and av.date_viewed >= DATE_SUB(CURDATE(),INTERVAL 7 DAY) group by av.AUDIOID ORDER BY viewcount desc limit $home_view_audios";
   /* if($category=="last_7")
        $queryCategory .= " AND last_viewed >= DATE_SUB(CURDATE(),INTERVAL 7 DAY) ";*/
}
if($category=="last_7")
	$query="SELECT a.AUDIOID,title,ext,count(a.AUDIOID) as viewcount,username,a.artist FROM audios AS a LEFT JOIN members AS m ON m.USERID = a.USERID left join audios_viewed av on av.AUDIOID=a.AUDIOID WHERE public='1' AND active='1' and av.date_viewed >= DATE_SUB(CURDATE(),INTERVAL 7 DAY) group by av.AUDIOID ORDER BY viewcount desc limit $home_view_audios";
else	
	$query="SELECT a.AUDIOID,title,ext,viewcount,username,artist FROM audios AS a LEFT JOIN members AS m ON m.USERID = a.USERID WHERE public='1' AND active='1' $queryCategory ORDER BY viewcount desc limit $home_view_audios";

$executequery = $conn->Execute($query);
if($executequery->recordcount()>0)
$vaudios = $executequery->getrows();
STemplate::assign('vaudios',$vaudios);
//MOST VIDEOS AUDIOS END

$pagetitle = "Top Videos";
STemplate::assign('pagetitle',$pagetitle);

//TEMPLATES BEGIN
STemplate::display('topvideos.tpl');
STemplate::display('footer.tpl');
//TEMPLATES END
?>